<?php
/**
 * @copyright Copyright (C) 2010 redCOMPONENT.com. All rights reserved.
 * @license GNU/GPL, see license.txt or http://www.gnu.org/copyleft/gpl.html
 * Developed by email@recomponent.com - redCOMPONENT.com
 *
 * redSHOP can be downloaded from www.redcomponent.com
 * redSHOP is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License 2
 * as published by the Free Software Foundation.
 *
 * You should have received a copy of the GNU General Public License
 * along with redSHOP; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
defined ( '_JEXEC' ) or die ( 'Restricted access' );
$uri =& JURI::getInstance();
$url= $uri->root();
JHTML::_('behavior.tooltip');
//$editor =& JFactory::getEditor();
JHTMLBehavior::modal();

?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">

	<tr>
		<td>
		<fieldset class="adminform"><legend><?php echo JText::_( 'COM_REDSHOP_PRODUCT_ATTRIBUTES' ); ?></legend>
		<table class="admintable" width="100%" border="0" cellspacing="0" cellpadding="0" >
			<tr>
				<td colspan="2">
				<div><?php echo JText::_('COM_REDSHOP_HINT_ATTRIBUTE');?></div>
				</td>
			</tr>
			<tr>
				<td colspan="2"><?php echo JText::_('COM_REDSHOP_COPY_ATTRIBUTES_FROM_ATTRIBUTE_SET');?></td>
			</tr>
			<tr>
				<td align="right" class="key"><?php echo JText::_('COM_REDSHOP_COPY');?></td>
				<td><?php echo $this->lists['copy_attribute'];?></td>
			</tr>
			<tr>
				<td valign="top" align="right" class="key"><?php echo JText::_( 'COM_REDSHOP_PRODUCT_ATTRIBUTE_SET_LBL' ); ?>:
				</td>
				<td><?php echo $this->lists['attributesSet'];?> 
				<?php echo JHTML::tooltip(JText::_( 'COM_REDSHOP_TOOLTIP_PRODUCT_ATTRIBUTE_SET' ), JText::_( 'COM_REDSHOP_PRODUCT_ATTRIBUTE_SET_LBL' ), 'tooltip.png', '', '', false); ?></td>
			</tr>
			<tr>
				<td colspan="2">
					<a class="btn_attribute" href="javascript:addNewRow_attribute('attribute_table')"> 
						<span id="new_attribute"><?php echo "+ "; echo JText::_( 'COM_REDSHOP_NEW_ATTRIBUTE' ); ?></span>
					</a>
				</td>
			</tr>
		</table>
		</fieldset>
		</td>
	</tr>
	
	<tr>
		<td>
			<table width="100%" cellpadding="2" border="0" id="attribute_table" cellspacing="2">
		
	<tr>
		<td colspan="5" align="right">
		<span id="atitle" 	style="display: none;">
			<?php echo JText::_('COM_REDSHOP_TITLE' ); ?>
		</span>
		<span id="atitlerequired" style="display: none;">
						<?php echo JText::_('COM_REDSHOP_ATTRIBUTE_REQUIRED');?>
		</span>
		<span id="atitlepublished" style="display: none;">
			<?php echo JText::_('COM_REDSHOP_PUBLISHED' ); ?>
		</span>
		<span id="spn_allow_multiple_selection" style="display: none;">
			<?php echo JText::_('COM_REDSHOP_ALLOW_MULTIPLE_PROPERTY_SELECTION');?>
		</span>
		<span id="spn_hide_attribute_price" style="display: none;">
			<?php echo JText::_('COM_REDSHOP_HIDE_ATTRIBUTE_PRICE');?>
		</span>
		<span id="spn_display_type" style="display: none;">
			<?php echo JText::_('COM_REDSHOP_DISPLAY_ATTRIBUTE_TYPE');?>
		</span>
		<span id="aproperty" style="display: none;">
			<?php echo JText::_('COM_REDSHOP_SUB_ATTRIBUTE' ); ?>
		</span>
	    <span id="aprice" style="display: none;">
	    	<?php echo JText::_('COM_REDSHOP_PRICE' ); ?>
	    </span>
		<span id="new_property" style="display: none;">
			<?php echo JText::_('COM_REDSHOP_SUB_ATTRIBUTE' ); ?>
		</span>
	    <span id="new_sub_property" style="display: none;">
	    	<?php echo JText::_('COM_REDSHOP_NEW_SUB_PROPERTY' ); ?>
	    </span>
		<span id="sub_atitlerequired" style="display: none;">
			<?php echo JText::_('COM_REDSHOP_SUBATTRIBUTE_REQUIRED');?>
		</span>
		<span id="sub_multiselected" style="display: none;">
			<?php echo JText::_ ( 'COM_REDSHOP_SUBATTRIBUTE_MULTISELECTED' );?>
		</span>
		<span id="delete_attribute" style="display: none;">
			<?php echo JText::_('COM_REDSHOP_DELETE_ATTRIBUTE' ); ?>
		</span>
		<span id="aimage" style="display: none;">
			<?php echo JText::_('COM_REDSHOP_IMAGE_UPLOAD' ); ?>
		</span>
		<span id="aordering" style="display: none;">
			<?php echo JText::_('COM_REDSHOP_ORDERING' ); ?>
		</span>
		<span id="adselected" style="display: none;">
			<?php echo JText::_('COM_REDSHOP_DEFAULT_SELECTED' ); ?>
		</span>
		<span id="showpropertytitlespan" style="display: none;">
			<?php echo JText::_('COM_REDSHOP_SUBPROPERTY_TITLE' ); ?>
		</span>
		</td>
	</tr>
	
	<?php
	$k = 0;$z = 1;
	if($this->lists['attributes'] != '')
	{

		foreach($this->lists['attributes'] as $attibute_data)
		{
			$checked_required		= "";
			$multiple_selection		= "";
			$hide_attribute_price	= "";
			$attribute_published = "";
			$attribute_published = "";
			$display_type = $attibute_data['display_type'];
			$attribute_id = $attibute_data['attribute_id'];
		
			if($attibute_data['attribute_required'] == 1)
			$checked_required = "checked='checked'";
		
			if($attibute_data['allow_multiple_selection'] == 1)
			$multiple_selection = "checked='checked'";
		
			if($attibute_data['hide_attribute_price'] == 1)
			$hide_attribute_price = "checked='checked'";
			if($attibute_data['attribute_published'] == 1)
			$attribute_published = "checked='checked'";


	?>
	<tr>
		<td>
		<table width="100%" border="0" cellspacing="0" cellpadding="0" id="<?php echo "attribute_table".$attribute_id;?>">
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0" class="blue_area" id="attribute_table">
			<tr>
			    <td width="2%"><img src="../administrator/components/com_redshop/assets/images/arrow.png" alt="img" /></td>
			    <td width="10%" class="red_blue_blue"><span><?php echo JText::_( 'COM_REDSHOP_TITLE' ); ?></span></td>
			    <td width="14%"><input style="width:180px;" type="text" class="text_area input_t1" size="55" name="attribute[<?php echo $k;?>][name]" value="<?php echo htmlspecialchars(urldecode($attibute_data['attribute_name'])); ?>"></td>
			    <td width="5%"><span><?php echo JText::_( 'COM_REDSHOP_ORDERING' ); ?></span>:</td>
			    <td width="4%"><input style="width:40px;" class="input_t1" type="text" name="attribute[<?php echo $k;?>][ordering]" size="3" value="<?php echo $attibute_data['ordering']; ?>"></td>
			    <td width="8%"><span><?php echo JText::_('COM_REDSHOP_ATTRIBUTE_REQUIRED');?></span>:</td>
			    <td width="4%"><input type="checkbox" class="text_area" size="55" name="attribute[<?php echo $k;?>][required]" <?php echo $checked_required;?> value="1"></td>
			    <td width="7%"><span><?php echo JText::_('COM_REDSHOP_PUBLISHED');?></span>:</td>
			    <td width="5%"><input type="checkbox" class="text_area" size="55" name="attribute[<?php echo $k;?>][published]" <?php echo $attribute_published;?> value="1"></td>
			    <td width="40%" align="right">
			    		<input style="cursor:pointer;" class="btn_attribute" value="<?php echo JText::_( 'COM_REDSHOP_DELETE_ATTRIBUTE' ); ?>" onclick="if(ajax_delete_attribute(<?php echo $this->detail->product_id?>,<?php echo $attribute_id;?>,0)){deleteRow_attribute('<?php echo "attribute_table".$attribute_id;?>','attribute_table','property_table<?php echo $k;?>',<?php echo $attibute_data['attribute_id']; ?>);}" type="button" />
				  		<input type="hidden" name="attribute[<?php echo $k;?>][id]" value="<?php echo $attibute_data['attribute_id']; ?>">
				</td>
		  </tr>
		</table></td>
  </tr>
  <tr>
    <td ><table width="100%" border="0" cellspacing="0" cellpadding="0" class="grey_area">
			<tr>
		    <td width="12%"><a class="btn_attribute" href="javascript:addproperty('property_table<?php echo $k;?>','<?php echo $k;?>')">
						<span><?php echo "+ "; echo JText::_( 'COM_REDSHOP_ADD_SUB_ATTRIBUTE' ); ?></span></a>
			</td>
		    <td width="12%">
		    		<span>
						<?php echo JText::_('COM_REDSHOP_ALLOW_MULTIPLE_PROPERTY_SELECTION');?>
					</span>
			</td>
		    <td width="2%"><input type="checkbox" size="5" name="attribute[<?php echo $k;?>][allow_multiple_selection]" <?php echo $multiple_selection;?>></td>
		    <td width="5%"></td>
		    <td width="4%"></td>
		    <td width="8%"></td>
		    <td width="4%"></td>
		    <td width="7%">
		    		<span>
						<?php echo JText::_('COM_REDSHOP_HIDE_ATTRIBUTE_PRICE');?>
					</span>
			</td>
		    <td width="5%"><input type="checkbox" size="5" name="attribute[<?php echo $k;?>][hide_attribute_price]" <?php echo $hide_attribute_price;?>></td>
		    <td width="40%" align="right">
		    		<span>
						<?php echo JText::_('COM_REDSHOP_DISPLAY_ATTRIBUTE_TYPE');?>
					</span>
					
					<select name="attribute[<?php echo $k;?>][display_type]">
						<option value="dropdown" <?php if($display_type =="dropdown") { echo "selected";}?>><?php echo JText::_('COM_REDSHOP_SINGLE_SELECT_BOX');?></option>
						<option value="radio" <?php if($display_type =="radio") {echo "selected";}?>><?php echo JText::_('COM_REDSHOP_RADIOBOX');?></option>
					</select></td>
		  </tr>
			<tr>
				<td colspan="10">
				<div class="speac-area">
				<table width="100%" border="0" cellspacing="0" cellpadding="0" class="grey_solid_area" id="property_table<?php echo $k;?>">
					<?php
					    $y=0;
						$g = 0;
						foreach($attibute_data['property'] as $property){
							$y++;
						  	if(count($attibute_data['property'][$g]->subvalue)>0){
						   		$style='style="display:block;"';
						   	}else{
						   		$style='style="display:none;"';
						   	}
						
					?>
				<tr valign="top">
		    	<td>
		    		<table width="100%" border="0" cellspacing="0" cellpadding="0" id="property_table<?php echo $property->property_id;?>" >
		          	<tr valign="top">
		            <td width="2%"><img src="../administrator/components/com_redshop/assets/images/arrow.png" alt="img" /></td>
				    <td width="10%" class="red_blue_blue">
				    		<span>
								<?php echo JText::_( 'COM_REDSHOP_SUB_ATTRIBUTE' ); ?>
							</span>
					</td>
				    <td width="14%">
				    	<input style="width:180px;" type="text" class="text_area input_t1" size="30"
									name="attribute[<?php echo $k;?>][property][<?php echo $g;?>][name]"
									value="<?php echo htmlspecialchars(urldecode($property->property_name));?>">
					</td>
				    <td width="5%">
				    		<span>
								<?php echo JText::_( 'COM_REDSHOP_ORDERING' ); ?>
							</span>
					</td>
				    <td width="4%">
				    	<input style="width:40px;" type="text" class="text_area input_t1" size="3"
									name="attribute[<?php echo $k;?>][property][<?php echo $g;?>][order]"
									value="<?php echo $property->ordering; ?>">
					</td>
				    <td width="8%" align="right"><span>
								<?php echo JText::_( 'COM_REDSHOP_DEFAULT_SELECTED' ); ?>
							</span></td>
				    <td width="4%">
				    	<input type="checkbox" name="attribute[<?php echo $k;?>][property][<?php echo $g;?>][default_sel]"
									<?php
											if($property->setdefault_selected==1)
											{
													echo "checked";
											}
									?>>
					</td>
				    <td width="4%">
				    		<span>
								<?php echo JText::_( 'COM_REDSHOP_PRICE' ); ?>
							</span>
					</td>
				    <td width="2%"><input style="width:15px;" type="text" class="text_area input_t1" size="1" style="text-align: center;" id="oprand<?php echo $k.$g;?>" value="<?php echo $property->oprand;?>"
							name="attribute[<?php echo $k;?>][property][<?php echo $g;?>][oprand]" maxlength="1"
							onchange="javascript:oprand_check(this);"></td>
				    <td width="3%"><input style="width:25px;" type="text" class="text_area input_t1" size="12" value="<?php echo $property->property_price;?>"
							name="attribute[<?php echo $k;?>][property][<?php echo $g;?>][price]" ></td>
							
				    <td width="43%" align="right">
			    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
			    		 <?php 
								$ilink = JRoute::_('index.php?tmpl=component&option=com_redshop&view=media&fsec=property&fid='.$k.$g.'&layout=thumbs');
								 $property_id = $property->property_id;
						  ?>	
			              <tr valign="top">
			                <td width="60%">
			                	<span>
									<div class="button2-left">
									<div class="image"><a class="modal" title="Image"
										href="<?php echo $ilink;?>"
										rel="{handler: 'iframe', size: {x: 900, y: 500}}"></a></div>
									</div>
								</span>	  
								<span>
									<input type="file"
									name="attribute_<?php echo $k;?>_property_<?php echo $g;?>_image"
									id="propfile<?php echo $k.$g;?>"
									value="<?php echo $property->property_image;?>">
								</span>
								<input value="Remove" class='button' type='button' width="0"
									onclick="if(ajax_delete_property(<?php echo $attribute_id;?>,<?php echo $property_id;?>)){deleteRow_property('<?php echo 'property_table'.$property->property_id ;?>','property_table<?php echo $k;?>','sub_attribute_table<?php echo $k.$g;?>',<?php echo $property_id;?>);}" />					
							
							</td>
							 <?php
								  $property_id = $property->property_id;
								  if($property_id)
								  {
							  ?>
			                <td width="40%" rowspan="1" align="right">
			               <a class="modal" rel="{handler: 'iframe', size: {x: 950, y: 500}}" title=""
								href="index.php?tmpl=component&option=com_redshop&amp;view=product_detail&amp;fsec=property&amp;section_id=<?php echo $property_id;?>&amp;cid=<?php echo $this->detail->product_id; ?>&amp;layout=property_images&amp;showbuttons=1">
								<img src="<?php echo REDSHOP_ADMIN_IMAGES_ABSPATH;?>media16.png" align="absmiddle" alt="media">
						  	</a>
							<a class="modal" rel="{handler: 'iframe', size: {x: 950, y: 500}}" title=""
								href="index.php?tmpl=component&option=com_redshop&amp;view=attributeprices&amp;section_id=<?php echo $property_id;?>&amp;cid=<?php echo $this->detail->product_id; ?>&amp;section=property">
								<img src="<?php echo REDSHOP_ADMIN_IMAGES_ABSPATH;?>discountmanagmenet16.png" align="absmiddle" alt="media">
							</a>
							<a class="modal" rel="{handler: 'iframe', size: {x: 950, y: 500}}" title=""
								href="index.php?tmpl=component&option=com_redshop&amp;view=product_detail&amp;section_id=<?php echo $property_id;?>&amp;cid=<?php echo $this->detail->product_id; ?>&amp;layout=productstockroom&amp;property=property"	>
								<img src="<?php echo REDSHOP_ADMIN_IMAGES_ABSPATH;?>stockroom16.png" align="absmiddle" alt="media">
							</a>	                
			                </td>
			               <?php } ?>
			               
			              </tr>
			              <tr>
			                <td>  
			                	 <img id="propertyImage<?php echo $k.$g;?>" src="" style="display: none;" />
								<?php
								if ($property->property_image != "")
								{
									$property->property_image;
									$impath =  REDSHOP_FRONT_IMAGES_ABSPATH.'product_attributes/'.$property->property_image;
									$impath_phy =  REDSHOP_FRONT_IMAGES_RELPATH.'product_attributes/'.$property->property_image;
		
									if (is_file($impath_phy))
									{
								?>
									<span id="property_image_<?php echo $property->property_id;?>">
										<a class="modal" title="<?php echo $property->property_image;?>" rel="{handler: 'image', size: {}}"
												href="<?php echo REDSHOP_FRONT_IMAGES_ABSPATH.'product_attributes/'.$property->property_image; ?>">
											<img alt='' title='' src='<?php echo $url?>components/com_redshop/helpers/thumb.php?filename=product_attributes/<?php echo $property->property_image?>&newxsize=50&newysize=0&swap=1'>
										</a>
										<a title="<?php echo JText::_('COM_REDSHOP_REMOVE_IMAGE');?>"
												href="javascript:removePropertyImage('<?php echo $property->property_id;?>','property');">
											<img src="<?php echo REDSHOP_FRONT_IMAGES_ABSPATH.'cross.jpg';?>">
										</a>
									</span>
							  <?php
									}
								}
								$ilink = JRoute::_('index.php?tmpl=component&option=com_redshop&view=media&fsec=property&fid='.$k.$g.'&layout=thumbs');
								?>			                
			                </td>
			                <td align="right">					   
						    	 <a class="btn_attribute" href="javascript:showpropertytitle('<?php echo $k.$g;?>'); addsubproperty('sub_attribute_table<?php echo $k.$g;?>','<?php echo $k;?>','<?php echo $g;?>')">
								<span id="new_sub_property">
									<?php echo "+ "; echo JText::_( 'COM_REDSHOP_NEW_SUB_PROPERTY' ); ?>
								</span>
							</a>				    	    
							</td>
			              </tr>
			              <tr>
			                <td>
			                	 <?php
									  $property_id = $property->property_id;
									  if($property_id)
									  {
									  	?>	 
										
										  	 <span>
										  	 	<?php echo JText::_( 'COM_REDSHOP_PROPERTY_NUMBER' ); ?>
										  	 </span>
											<input style="width:90px;" type="text" value="<?php echo $property->property_number; ?>" name="attribute[<?php echo $k;?>][property][<?php echo $g;?>][number]" class="vpnrequired input_t1" size="15" >
											 
								  <?php } 
										$ilink = JRoute::_('index.php?tmpl=component&option=com_redshop&view=media&fsec=property&fid='.$k.$g.'&layout=thumbs');
								  ?>		
			                
			                </td>
			                <input type="hidden" name="attribute[<?php echo $k;?>][property][<?php echo $g;?>][property_id]" value="<?php echo $property_id;?>">
							<input type="hidden" name="imagetmp[<?php echo $k;?>][value][]" value="<?php echo $property->property_image;?>">
							<input type="hidden" name="attribute[<?php echo $k;?>][property][<?php echo $g;?>][mainImage]" id="propmainImage<?php echo $k.$g;?>" value="">
			              </tr>
			        </table>	
			    	</td>
			        </tr>
			 	 </table>
			    </td>
			  </tr>
			  
		<!-- START MY CODE -->	
		<tr>
		    <td>
		<table width="100%" border="0" cellspacing="0" cellpadding="0" id="sub_attribute_table<?php echo $k.$g;?>" >			
			 <tr>
		    <td>
		       <table width="100%" border="0" cellspacing="0" cellpadding="0" >
		          <tr valign="top">
		            <td width="2%"></td>
		    <div <?php echo $style?> id='showsubproperty<?php echo $k.$g;?>'>
		    <td width="10%" class="red_blue_blue">
			   
			    	<?php echo JText::_( 'COM_REDSHOP_SUBPROPERTY_TITLE' ); ?>					
			    	    
		    </td>
		    <td width="14%">		    
		    	<input style="width:180px;" class="input_t1" type="text" name="attribute[<?php echo $k;?>][property][<?php echo $g?>][subproperty][title]" size="15"
					value="<?php echo (count($attibute_data['property'][$g]->subvalue)>0) ? $attibute_data['property'][$g]->subvalue[0]->subattribute_color_title : ""; ?>">
		    </td>
		    <td width="5%"></td>
		    <td width="4%"></td>
		    <td width="8%" align="right"><span><?php echo JText::_('COM_REDSHOP_SUBATTRIBUTE_REQUIRED');?></span></td>
		    <td width="4%">
		    	<input type="checkbox" name="attribute[<?php echo $k;?>][property][<?php echo $g;?>][req_sub_att]"
											<?php
													if($property->setrequire_selected==1)
													{
															echo "checked";
													}
											?>>
			</td>
		    <td width="6%"><span><?php echo JText::_('COM_REDSHOP_SUBATTRIBUTE_MULTISELECTED');?></span></td>
		    <td width="3%"><input type="checkbox" name="attribute[<?php echo $k;?>][property][<?php echo $g;?>][multi_sub_att]"
											<?php
													if($property->setmulti_selected==1)
													{
															echo "checked";
													}
											?>>
			</td>
		    <td width="43%" > <span><?php echo JText::_('COM_REDSHOP_DISPLAY_ATTRIBUTE_TYPE');?></span>  
			    <select name="attribute[<?php echo $k;?>][property][<?php echo $g;?>][setdisplay_type]">
											<option value="dropdown" <?php if($property->setdisplay_type =="dropdown") { echo "selected";}?>><?php echo JText::_('COM_REDSHOP_SINGLE_SELECT_BOX');?></option>
											<option value="radio" <?php if($property->setdisplay_type =="radio") {echo "selected";}?>><?php echo JText::_('COM_REDSHOP_RADIOBOX');?></option>
											
				</select>
		    	
		    </td>
		    </div>	
		          </tr>
		 	 </table>
		    </td>
		  	</tr> 
		 	  
		 <tr>
		    <td>
			   <table width="100%" border="0" cellspacing="0" cellpadding="0" >
				
				<!--  <td class="red_blue_blue">					   
				    	 <a class="btn_attribute" href="javascript:showpropertytitle('<?php echo $k.$g;?>'); addsubproperty('sub_attribute_table<?php echo $k.$g;?>','<?php echo $k;?>','<?php echo $g;?>')">
						<span id="new_sub_property">
							<?php //echo "+ "; echo JText::_( 'COM_REDSHOP_NEW_SUB_PROPERTY' ); ?>
						</span>
					</a>				    	    
				</td>-->
				
					 <?php
					$total_subattr = count($attibute_data['property'][$g]->subvalue);
					if($total_subattr != 0)
					{
						$sub_inc = 0;
						$sp = 0;
						foreach($attibute_data['property'][$g]->subvalue as $subvalue)
						{
							$sub_inc++;
							$impath =  REDSHOP_FRONT_IMAGES_ABSPATH.'subcolor/'.$subvalue->subattribute_color_image;
							$impathphy =  REDSHOP_FRONT_IMAGES_RELPATH.'subcolor/'.$subvalue->subattribute_color_image;
							$ilink = JRoute::_('index.php?tmpl=component&option=com_redshop&view=media&fsec=subproperty&fid='.$k.$z.'&layout=thumbs');
					?>
					<tr>
					<td>
					<table width="100%" border="0" cellspacing="0" cellpadding="0" id="sub_attribute_table<?php echo $subvalue->subattribute_color_id;?>">
		                       <tr valign="top">
                                <!--<td width="12%">
	                                <a class="btn_attribute" href="javascript:showpropertytitle('<?php echo $k.$g;?>'); addsubproperty('sub_attribute_table<?php echo $k.$g;?>','<?php echo $k;?>','<?php echo $g;?>')">
										<span id="new_sub_property">
											<?php //echo "+ "; echo JText::_( 'COM_REDSHOP_NEW_SUB_PROPERTY' ); ?>
										</span>
									</a>	                                
                                </td>-->
		                        <td width="7%"><?php echo JText::_( 'COM_REDSHOP_PARAMETER' ); ?>:</td>
		                        <td width="7%"><input style="width:90px;" type="text" class="text_area input_t1" size="30" name="attribute[<?php echo $k;?>][property][<?php echo $g;?>][subproperty][<?php echo $sp;?>][name]" value="<?php echo htmlspecialchars(urldecode($subvalue->subattribute_color_name));?>"></td>
		                        <td width="5%"><span><?php echo JText::_( 'COM_REDSHOP_ORDERING' ); ?></span></td>
		                        <td width="4%"><input style="width:40px;" class="input_t1" type="text" name="attribute[<?php echo $k;?>][property][<?php echo $g;?>][subproperty][<?php echo $sp;?>][order]" size="3" value="<?php echo $subvalue->ordering; ?>"></td>
		                        <td width="8%" align="right"><span><?php echo JText::_( 'COM_REDSHOP_DEFAULT_SELECTED' ); ?></span></td>
		                        <td width="4%"><input type="checkbox" name="attribute[<?php echo $k;?>][property][<?php echo $g;?>][subproperty][<?php echo $sp;?>][chk_propdselected]" <?php if($subvalue->setdefault_selected==1){echo "checked";}?>	value="1" /></td>
		                        <td width="4%"><span><?php echo JText::_( 'COM_REDSHOP_PRICE' ); ?></span></td>
		                        <td width="2%"><input style="width:15px;" class="input_t1" type="text" class="text_area" size="1" name="attribute[<?php echo $k;?>][property][<?php echo $g;?>][subproperty][<?php echo $sp;?>][oprand]" maxlength="1" value="<?php echo $subvalue->oprand;?>" style="text-align: center;" id="oprand<?php echo $k.$g;?>" onchange="javascript:oprand_check(this);"></td>
		                        <td width="3%"><input style="width:25px;" class="input_t1" type="text" class="text_area" size="12" name="attribute[<?php echo $k;?>][property][<?php echo $g;?>][subproperty][<?php echo $sp;?>][price]" value="<?php echo $subvalue->subattribute_color_price;?>"></td>
		                        
					<!-- START MY CODE -->
					<td width="43%" align="right">
                            			<table width="100%" border="0" cellspacing="0" cellpadding="0">
						      <tr valign="top">
							<td width="80%">
								<img id="subpropertyImage<?php echo $k.$z;?>" src="" style="display: none;" />
								<span>
									<div class="button2-left">
										<div class="image"><a class="modal" title="Image" href="<?php echo $ilink;?>" rel="{handler: 'iframe', size: {x: 900, y: 500}}"></a>
										</div>
									</div>
								</span> 
								<input type="file" name="attribute_<?php echo $k;?>_property_<?php echo $g;?>_subproperty_<?php echo $sp;?>_image" value="<?php echo $subvalue->subattribute_color_image;?>">
								<input value="Remove" class='button' type='button' width="0"
										onclick="if(ajax_delete_subproperty(<?php echo $subvalue->subattribute_color_id;?>,<?php echo $property_id;?>)){deleteRow_subproperty('<?php echo 'sub_attribute_table'.$subvalue->subattribute_color_id ;?>','sub_attribute_table<?php echo $k.$g;?>',<?php echo $subvalue->subattribute_color_id;?>);}" />
							</td>
							<td width="20%" rowspan="3" align="right">
								<?php if($subvalue->subattribute_color_id != 0)
								{?>
								   <a class="modal"
										href="index.php?tmpl=component&option=com_redshop&amp;view=product_detail&amp;fsec=subproperty&amp;section_id=<?php echo $subvalue->subattribute_color_id;?>&amp;cid=<?php echo $this->detail->product_id; ?>&amp;layout=property_images&amp;showbuttons=1"
										rel="{handler: 'iframe', size: {x: 950, y: 500}}" title=""><img
										src="<?php echo REDSHOP_ADMIN_IMAGES_ABSPATH;?>media16.png"
										align="absmiddle" alt="media"></a>
									<a class="modal" rel="{handler: 'iframe', size: {x: 950, y: 500}}" title=""
										href="index.php?tmpl=component&option=com_redshop&amp;view=attributeprices&amp;section_id=<?php echo $subvalue->subattribute_color_id;?>&amp;cid=<?php echo $this->detail->product_id; ?>&amp;section=subproperty" >
										<img src="<?php echo REDSHOP_ADMIN_IMAGES_ABSPATH;?>discountmanagmenet16.png" align="absmiddle" alt="media">
									</a>
									<a class="modal" rel="{handler: 'iframe', size: {x: 950, y: 500}}" title=""
										href="index.php?tmpl=component&option=com_redshop&amp;view=product_detail&amp;section_id=<?php echo $subvalue->subattribute_color_id;?>&amp;cid=<?php echo $this->detail->product_id; ?>&amp;layout=productstockroom&amp;property=subproperty" >
										<img src="<?php echo REDSHOP_ADMIN_IMAGES_ABSPATH;?>stockroom16.png" align="absmiddle" alt="media">
									</a>
								<?php } ?>

							</td>
						       
						      </tr>
						      <tr>
							<td>  
								<?php
								if ($subvalue->subattribute_color_image != "" && is_file($impathphy))
								{
								?>
								<span id="subproperty_image_<?php echo $subvalue->subattribute_color_id;?>">
									<a class="modal" rel="{handler: 'image', size: {}}" title="<?php echo $subvalue->subattribute_color_image;?>"
										href="<?php echo REDSHOP_FRONT_IMAGES_ABSPATH.'subcolor/'.$subvalue->subattribute_color_image; ?>" >
										<img src='<?php echo $url?>components/com_redshop/helpers/thumb.php?filename=subcolor/<?php echo $subvalue->subattribute_color_image;?>&newxsize=50&newysize=0&swap=1' alt='' title=''>
									</a>
									<a href="javascript:removePropertyImage('<?php echo $subvalue->subattribute_color_id;?>','subproperty');" title="<?php echo JText::_('COM_REDSHOP_REMOVE_IMAGE');?>">
										<img src="<?php echo REDSHOP_FRONT_IMAGES_ABSPATH.'cross.jpg';?>">
									</a>
								</span>
								<?php
								}
								?>
							</td>
						      </tr>
						      <tr>
							<td>
								<?php if($subvalue->subattribute_color_id != 0)
								{?>
								 <span><?php echo JText::_( 'COM_REDSHOP_SUBPROPERTY_NUMBER' ); ?></span>
									<input type="text" size="15" value="<?php echo $subvalue->subattribute_color_number; ?>"
												name="attribute[<?php echo $k;?>][property][<?php echo $g;?>][subproperty][<?php echo $sp;?>][number]" class="vpnrequired" >
								<?php } ?>
							
							<input type="hidden" name="attribute[<?php echo $k;?>][property][<?php echo $g;?>][subproperty][<?php echo $sp;?>][subproperty_id]" value="<?php echo $subvalue->subattribute_color_id;?>">
							<input type="hidden" name="imagetmp[<?php echo $k;?>][subvalue][<?php echo $g;?>][]" value="<?php echo $subvalue->subattribute_color_image;?>">
							<input type="hidden" name="attribute[<?php echo $k;?>][property][<?php echo $g;?>][subproperty][<?php echo $sp;?>][mainImage]" id="subpropmainImage<?php echo $k.$z;?>" value="">
							</td>
						      </tr>
						</table>
                        		</td>
					<!-- END MY CODE -->
		                      </tr>
		                      
		                    </table>
		              </td>
				</tr>
					<?php
						$sp++;
						$z++;
						}
					}
					else
					{
						$ilink = JRoute::_('index.php?tmpl=component&option=com_redshop&view=media&fsec=subproperty&fid='.$k.$z.'&layout=thumbs');
?>

<tr style="display: none;">
							<td>
								<input type="text" class="text_area" size="40" name="property[<?php echo $k;?>][subvalue][][]" value="">
							</td>
							<td>
								<span><?php echo JText::_( 'COM_REDSHOP_PRICE' ); ?></span>
							</td>
							<td>
								<input type="text" class="text_area" size="1" name="oprand[<?php echo $k;?>][subvalue][][]" maxlength="1" value="+" style="text-align: center;" id="oprand<?php echo $k.$g;?>" onchange="javascript:oprand_check(this);">
							</td>
							<td>
								<input type="text" class="text_area" size="12" name="price[<?php echo $k;?>][subvalue][][]" value="">
							</td>
							<td>
						    	<img id="subpropertyImage<?php echo $k.$z;?>" src="" style="display: none;" />
						    	<span>
									<div class="button2-left">
										<div class="image"><a class="modal" title="Image" href="<?php echo $ilink;?>" rel="{handler: 'iframe', size: {x: 900, y: 500}}"></a>
										</div>
									</div>
									</span>
										<input type="file" name="image[<?php echo $k;?>][subvalue][][]">
										<input value="Remove" class='button' type='button' width="0"
										onclick="deleteRow_subproperty(this,'sub_attribute_table<?php echo $k.$g;?>');" />
										<input type="hidden" name="property_id[<?php echo $k;?>][subvalue][][]" value="">
										<input type="hidden" name="imagetmp[<?php echo $k;?>][subvalue][][]" value="">
										<input type="hidden" name="mainImage[<?php echo $k;?>][subvalue][][]" id="subpropmainImage<?php echo $k.$g;?>" value="">
							</td>
						</tr>
<?php					}
?>			
			</table>
		    </td>
		</tr>
		</table>
		</td>
		</tr>  
		<!-- End MY CODE -->
		
					<?php $g++;
						}
					?>	
				</table>
				</div>
				</td>
			</tr>
			
		</table></td>
  </tr>
</table>
		</td>
	</tr>
	
	<?php $k++;
	}
	?>
		   <span id="delete_attribute" style="display: none;"><?php echo JText::_( 'COM_REDSHOP_DELETE_ATTRIBUTE' ); ?></span>
			<span id="aimage" style="display: none"><?php echo JText::_( 'COM_REDSHOP_IMAGE_UPLOAD' ); ?></span>
			<span id="aproperty" style="display: none"><?php echo JText::_( 'COM_REDSHOP_SUB_ATTRIBUTE' ); ?></span>
			<span id="aprice" style="display: none"><?php echo JText::_( 'COM_REDSHOP_PRICE' ); ?></span>
			<tr>
				<td colspan="5"><input type="hidden" name="total_table"
					id="total_table" value="<?php echo $k;?>"> <input type="hidden"
					name="total_g" id="total_g" value="<?php echo $g;?>"> <input
					type="hidden" name="total_z" id="total_z" value="<?php echo $z;?>">
				</td>
			</tr> 
<?php
	}
	else
	 {
		$g=1;
		$z=1;
?>
		 <tr>
			<td colspan="5">
				<input type="hidden" name="total_table" id="total_table" value="<?php echo $k;?>">
				<input type="hidden" name="total_g" id="total_g" value="<?php echo $g;?>">
				<input type="hidden" name="total_z" id="total_z" value="<?php echo $z;?>">
			</td>
		</tr> 
<?php }
?>
	</table>
	</td>
	</tr>
</table>